"""
配置管理模块
用于管理环境变量和系统配置
"""

import os
from dotenv import load_dotenv

# 加载环境变量
load_dotenv()

class Config:
    """系统配置类"""
    
    # 阿里云百炼API配置
    DASHSCOPE_API_KEY = os.getenv("DASHSCOPE_API_KEY")
    
    # 高德地图API配置
    AMAP_API_KEY = os.getenv("AMAP_API_KEY")
    
    # Qdrant配置
    QDRANT_HOST = os.getenv("QDRANT_HOST", "localhost")
    QDRANT_PORT = int(os.getenv("QDRANT_PORT", "6333"))
    QDRANT_COLLECTION_NAME = os.getenv("QDRANT_COLLECTION_NAME", "travel_documents")
    QDRANT_PATH = os.getenv("QDRANT_PATH", "/Users/pengxiong/workspace/pyWorkspace/traval-agent/qdrant_db")
    
    # 文档处理配置
    CHUNK_SIZE = int(os.getenv("CHUNK_SIZE", "1000"))
    CHUNK_OVERLAP = int(os.getenv("CHUNK_OVERLAP", "200"))
    
    # 模型配置
    EMBEDDING_MODEL = "text-embedding-v1"  # 阿里云百炼文本嵌入模型
    LLM_MODEL = "qwen-turbo"  # 阿里云百炼大语言模型
    
    @classmethod
    def validate_config(cls):
        """验证配置是否完整"""
        if not cls.DASHSCOPE_API_KEY:
            raise ValueError("DASHSCOPE_API_KEY 环境变量未设置")
        return True
    
    @classmethod
    def validate_amap_config(cls):
        """验证高德地图配置是否完整"""
        if not cls.AMAP_API_KEY:
            raise ValueError("AMAP_API_KEY 环境变量未设置")
        return True
